package com.qf.fmall.controller;

import com.qf.fmall.entity.Orders;
import com.qf.fmall.service.OrderService;
import com.qf.fmall.vo.PageInfoVo;
import com.qf.fmall.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/order")
public class OrderController {
    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @CrossOrigin
    public ResultVo addOrders(String cids, @RequestBody Orders orders) {
        ResultVo resultVo = orderService.addOrders(cids, orders);
        return resultVo;
    }

    @CrossOrigin
    @RequestMapping(value = "/status/{oid}", method = RequestMethod.GET)
    public ResultVo statusOrders(@PathVariable("oid") String oid) {
        ResultVo resultVo = orderService.statusOrders(oid);
        return resultVo;
    }

    @CrossOrigin
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResultVo listOrders(Integer userId,  Integer pageNum, Integer limit) {
        ResultVo resultVo = orderService.ListOrders(userId,pageNum,limit);
        return resultVo;
    }
}
